package com.ybkj.chat.module.login.activity;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.ybkj.chat.R;
import com.ybkj.chat.base.BaseMvpActivity;
import com.ybkj.chat.manager.ActivityManager;
import com.ybkj.chat.module.login.presenter.RegisterPresenter1;
import com.ybkj.chat.module.login.view.RegisterPresenterView1;
import com.ybkj.chat.ui.view.ClearEditText;
import com.ybkj.chat.utils.EditTextInputHelper;
import com.ybkj.chat.utils.VerificationCodeUtil;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 注册第一步
 */
public class Register1Activity extends BaseMvpActivity<RegisterPresenter1> implements RegisterPresenterView1 {


    @BindView(R.id.tip_tv)
    TextView tipTv;
    //注册账号
    @BindView(R.id.et_account)
    ClearEditText etAccount;
    //手机验证码
    @BindView(R.id.register_phone_code_et)
    EditText registerPhoneCodeEt;
    //获取验证码
    @BindView(R.id.register_code_btn)
    TextView registerCodeBtn;
    //下一步
    @BindView(R.id.next_btn)
    Button next_btn;

    private EditTextInputHelper mEditTextInputHelper;

    @Override
    protected void injectPresenter() {
        getActivityComponent().inject(this);
    }

    @Override
    protected void initTitle() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_register1;
    }

    @Override
    protected void initView() {
//        next_btn.setOnClickListener(this);
        mEditTextInputHelper = new EditTextInputHelper(next_btn, false);
        mEditTextInputHelper.addViews(etAccount, registerPhoneCodeEt);
    }

    @Override
    protected void initData() {

    }

    @Override
    public boolean isImmersiveStatusBar() {
        return true;
    }


    @OnClick({R.id.register_code_btn, R.id.next_btn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            //获取验证码
            case R.id.register_code_btn:
                String phone = etAccount.getText().toString().trim();
                presenter.getPhoneCode(phone);
                break;
            //下一步
            case R.id.next_btn:
                ActivityManager.gotoActivity(mContext, Register2Activity.class);
                break;
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mEditTextInputHelper.removeViews();
    }


    public void verificationCodeChange() {
        VerificationCodeUtil util = new VerificationCodeUtil();
        util.codeCountDown(registerCodeBtn);
    }
}
